package com.linsen.core.satoken.props;

import com.linsen.core.satoken.constant.SaTokenConstant;
import com.linsen.core.satoken.strategy.JwtStrategy;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhaoyong
 * @date 2023/3/11
 */
@Data
@RefreshScope
@ConfigurationProperties(prefix = "linsen.sa-token")
public class LinsenSaTokenProperties {
    private Boolean saInterceptor = Boolean.FALSE;
    private List<String> saInterceptorAddPathPatterns = new ArrayList<String>() {{
//        add("/**");
    }};

    private List<String> saInterceptorExcludePathPatterns = new ArrayList<String>() {{
        add("/**");
    }};

    private Boolean jwt = Boolean.TRUE;

    private JwtStrategy jwtStrategy = JwtStrategy.STATELESS;

    @PostConstruct
    public void init() {
        saInterceptorExcludePathPatterns.addAll(SaTokenConstant.ENDPOINTS);
    }
}
